#include <iostream>
#include <hiredis/hiredis.h>

using std::cout;
using std::endl;

void test()
{
    redisContext *c = redisConnect("127.0.0.1", 6379);

    redisReply *r = static_cast<redisReply *>(redisCommand(c, "set hiredis hi,redis!"));
    cout << r->str << endl;

    redisCommand(c, "hset k b c");
    freeReplyObject(r);
    r = (redisReply *)redisCommand(c, "get hiredis");
    cout << r->str << endl;

    freeReplyObject(r);
    r = (redisReply *)redisCommand(c, "hgetall k");

    for (size_t idx{}; idx < r->elements;)
    {
        cout << r->element[idx++]->str << ": ";
        cout << r->element[idx++]->str << endl;
    }
}

int main(int args, char *argv[])
{
    test();
    return 0;
}